package com.td.erhome.ui.sellhouse;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.td.erhome.R;
import com.td.erhome.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class MarkActivity extends BaseActivity {


    @Bind(R.id.back)
    ImageView mBack;
    @Bind(R.id.tv_sure)
    TextView mTvSure;
    @Bind(R.id.et_mark)
    EditText mEtMark;
    @Bind(R.id.tv_num)
    TextView mTvNum;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_mark;
    }

    @Override
    protected void initView() {
        mEtMark.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                int length = mEtMark.getText().toString().length();
                mTvNum.setText(length+"/150");

            }
        });

    }

    @Override
    protected void releaseResource() {

    }

    @OnClick({R.id.back, R.id.tv_sure})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.tv_sure:
                Intent data = new Intent();
                data.putExtra("mark",mEtMark.getText().toString());
                setResult(RESULT_OK, data);
                finish();
                break;
        }
    }
}
